﻿/// <reference path="../Core.ts" />

module Supernova {

    export class BodyFacilityArtillery {

        public wait: number = 0;

        launch(sourceBody: Body, targetBody: Body, strength: number, ignoreOrbitals: boolean) {
            
            // Create a new artillery shell
            var shell = new Artillery(sourceBody, null, targetBody);
            shell.strength = strength;
            shell.ignoreOrbitals = ignoreOrbitals;
            galaxy.artillery.push(shell);

            // Communicate the launch if I am launching an artillery shell in multiplayer
            if (galaxy.mode == GameMode.multiplayer && sourceBody.system.owner == OwnerType.human) {
                channel.invoke.artilleryBodyBody(sourceBody.system.code, sourceBody.code, targetBody.system.code, targetBody.code, strength, ignoreOrbitals);
            }

            // Play sound if origin or destination body is human
            if (sourceBody.system.owner == OwnerType.human || targetBody.system.owner == OwnerType.human || galaxy.mode == GameMode.replay) {
                Sounds.play(Sounds.items.artillery);
            }
        }

    }

}